from google.appengine.ext import db
from domain import topic

class Comment(db.Model):

    topic = db.Reference(topic.Topic, required=True)
    message = db.TextProperty(required=True)
    date = db.DateTimeProperty(auto_now=True)
    enabled = db.BooleanProperty(True)
    user = db.UserProperty(required=True)
    nickname = db.StringProperty(required=True)

    def getKey(self):
        return self.key()

    def isValid(self):
        if (len(self.message) > 4000):
            return False
        return True
